/**
 * 
 */
package edu.hadassah.store.management;

import java.beans.PropertyChangeSupport;

import edu.hadassah.store.employee.IEmployee;
import edu.hadassah.store.order.IOrderInfo;
import edu.hadassah.store.uniqueid.IUniqueId;

/**
 * @author persikov
 *
 */
public final class NotificationManager {

	private final PropertyChangeSupport changeSupport;
	
	private static NotificationManager instance = new NotificationManager();

	private NotificationManager() {
		super();
		changeSupport = new PropertyChangeSupport(this);
	}

	/**
	 * @return the instance
	 */
	public static NotificationManager getInstance() {
		return instance;
	}
	
	public void notifyRemoveOrder(IUniqueId orderId,  IEmployee employee){
		changeSupport.removePropertyChangeListener(orderId.getIdAsString(), employee);
	}

	/**
	 * @param orderId
	 * @param employee
	 */
	public void addOrderListener(IUniqueId orderId, IEmployee employee) {
		changeSupport.addPropertyChangeListener(orderId.getIdAsString(), employee);
		
	}

	/**
	 * @param orderId
	 * @param oldOrderMemento
	 * @param updateOrder
	 */
	public void fireOrderChange(IUniqueId orderId, IOrderInfo oldOrderMemento,
			IOrderInfo updateOrder) {
		changeSupport.firePropertyChange(orderId.getIdAsString(), oldOrderMemento, updateOrder);
	}

	/**
	 * @param id
	 * @param employee
	 */
	public void removeOrderListener(IUniqueId id, IEmployee employee) {
		changeSupport.removePropertyChangeListener(id.getIdAsString(), employee);
	}



}
